{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 自动加载修改过的文件\n",
    "%load_ext autoreload\n",
    "%autoreload 2\n",
    "import os\n",
    "import sys\n",
    "import warnings\n",
    "sys.path.append('../')  # |返回notebook的上一级目录\n",
    "warnings.filterwarnings(\"ignore\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 Physical GPUs, 1 Logical GPUs\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "from utils.config_gpu import config_gpu\n",
    "config_gpu()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from utils.config import *\n",
    "from utils.saveLoader import load_text, get_text, load_dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "@tf.function\n",
    "def f(a):\n",
    "    print(\"The function is running in Python\")\n",
    "    b = [tf.constant(3., dtype=tf.float32)]\n",
    "    b += a\n",
    "    tf.print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[3, 11, 7]\r\n"
     ]
    }
   ],
   "source": [
    "a = [tf.constant(11., dtype=tf.float32), tf.constant(7., dtype=tf.float32)]\n",
    "f(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "Size must be declared for TensorArrays when eager execution is enabled.",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-15-55fe4336b799>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0ma\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mTensorArray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdtype\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mtf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfloat32\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdynamic_size\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mE:\\software\\Anaconda3\\envs\\tf2.0\\lib\\site-packages\\tensorflow_core\\python\\ops\\tensor_array_ops.py\u001b[0m in \u001b[0;36m__init__\u001b[1;34m(self, dtype, size, dynamic_size, clear_after_read, tensor_array_name, handle, flow, infer_shape, element_shape, colocate_with_first_write_call, name)\u001b[0m\n\u001b[0;32m   1006\u001b[0m         \u001b[0melement_shape\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0melement_shape\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1007\u001b[0m         \u001b[0mcolocate_with_first_write_call\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mcolocate_with_first_write_call\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1008\u001b[1;33m         name=name)\n\u001b[0m\u001b[0;32m   1009\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1010\u001b[0m     \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_implementation\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mparent\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mweakref\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mref\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mE:\\software\\Anaconda3\\envs\\tf2.0\\lib\\site-packages\\tensorflow_core\\python\\ops\\tensor_array_ops.py\u001b[0m in \u001b[0;36m__init__\u001b[1;34m(***failed resolving arguments***)\u001b[0m\n\u001b[0;32m    674\u001b[0m                        \"execution is enabled.\")\n\u001b[0;32m    675\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0msize\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 676\u001b[1;33m       raise ValueError(\"Size must be declared for TensorArrays when eager \"\n\u001b[0m\u001b[0;32m    677\u001b[0m                        \"execution is enabled.\")\n\u001b[0;32m    678\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mValueError\u001b[0m: Size must be declared for TensorArrays when eager execution is enabled."
     ]
    }
   ],
   "source": [
    "a = tf.TensorArray(dtype=tf.float32, dynamic_size=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [14712,480,1111,308,288,480,23,90,121,308,288,480,480,543,308,10,1111,554,27,152,5,34,11,665,1,68,539,1805,258,459,1111,75,722,1111,14713,491,744,385,263,20,431,14713,4939,288,141,103,457,659,5349,33,64,69,94,1071,14,385,2198,14714,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715,14715]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:tf2.0]",
   "language": "python",
   "name": "conda-env-tf2.0-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
